package ru.vpitervip.app.client.activity;

import ru.vpitervip.app.client.place.ContactsPlace;
import ru.vpitervip.app.client.place.FlatsPlace;
import ru.vpitervip.app.client.place.InformationPlace;
import ru.vpitervip.app.client.place.MainPlace;
import ru.vpitervip.app.client.place.PaymentPlace;
import ru.vpitervip.app.client.place.ServicesPlace;
import ru.vpitervip.app.client.request.AppRequestFactory;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.inject.Inject;

public class MasterActivityMapper implements ActivityMapper{

	
	private AppRequestFactory requestFactory;
	private PlaceController placeController;

	@Inject
	public MasterActivityMapper(AppRequestFactory requestFactory,PlaceController placeController) {
		this.requestFactory=requestFactory;
		this.placeController=placeController;
	}
	
	@Override
	public Activity getActivity(Place place) {
		
		if (place instanceof FlatsPlace) return new FlatsActivity((FlatsPlace)place, requestFactory, placeController);
		if (place instanceof MainPlace) return new MainActivity((MainPlace)place, requestFactory, placeController);
		if (place instanceof InformationPlace) return new InformationActivity((InformationPlace)place, requestFactory, placeController);
		if (place instanceof PaymentPlace) return new PaymentActivity((PaymentPlace)place,placeController);
		if (place instanceof ServicesPlace) return new ServicesActivity((ServicesPlace)place);
		if (place instanceof ContactsPlace) return new ContactsActivity((ContactsPlace)place, requestFactory, placeController);
		
		return null;
	}

}
